<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta content="user-scalable=no,width=device-width, initial-scale=1" id="viewport" name="viewport" initial-scale="1">

		<script language="javascript" type="text/javascript" src="../js/js/baseJs.js"></script>

	</head>
	<body style="background:#f5f9ff">

		<div class="wap-user-center" id="userCenter" style="display: none;">
			<div class="wap-header">个人中心
				<a class="back" onClick="javascript:window.history.back();return false;"></a>
				<a style="position: absolute;
    right: .2rem;color:#fff;font-size:.24rem" href="/userBundle/changePassword.mobile.html">修改密码</a>
			</div>
			<div class="user-center-bd">
				<div class="user-b">
					<div class="logo-c" v-if="userData.category!=='3'"><img src="../image/user_center_ico.png"></div>
					<div class="logo-c" v-if="userData.category=='3'"><img src="../image/gudong_touxiang_ico.png"></div>
					<div class="c-bd">
						<div class="user-name">用户：{{userData.telephone}}</div>
						<div class="user-type" v-if="accountType==0&&!isTeamLeader">类型：{{userData.category|userCategory}}</div>
						<div class="user-type" v-if="isTeamLeader">类型：
							<span href="#" style="color: #fff;">团长</span>
							<a class="info-c">权益</a>
						</div>
						
						<div class="user-type" v-if="userData.category=='3'">拥有股份：{{userData.stockNumber}}份</div>
						<div class="user-type">贡献值：{{userData.contributionValueTotal}}</div>
						<div class="user-name" v-if="userData.userDirect">指导老师：{{userData.userDirect.telephone}}手机</div>
					</div>
				</div>	
				<div style="display: flex;flex-direction: row;" v-if="accountType!==1">
					<a class="btn-vip" v-if="userData.category!=='2'" href="/publicBundle/becomeVip.mobile.html"><span class="ico"></span>成为VIP</a>
					<a class="btn-shareholder" v-if="userData.category!=='3'" href="/userBundle/becomeShareholder.mobile.html"><span
						 class="ico"></span>成为股东</a>
				</div>			
				<div>					
					<div class="gold-bander" v-if="accountType==1">
						<a href="./goldSeedCenter.html">
							<img src="../image/gold_ico.png" />
						</a>
					</div>
					<div class="gold-bander" v-if="accountType!==1&&isIng">
						<div @click="showMessageIng()">
							<img src="../image/gold_ico_ing.png" />
						</div>
					</div>
				</div>
				<!-- <div class="refund-info" v-if="refundReason.length>0&&accountType!==1">
					<div class="title">金种子申请被驳回</div>
					<div class="reason">由于：{{refundReason[0].reason}}</div>
				</div> -->
				<div class="l-content-bd" v-if="userData.category=='3'">
					<a class="l-content" href="/userBundle/shareholderDividends.mobile.html">
						<span class="score"></span>
						<div class="title">分红列表</div>
						<span class="arrow"></span>
					</a>
					<a class="l-content" href="/userBundle/scoreWithdraw.mobile.html">
						<span class="score"></span>
						<div class="title">我的积分</div>
						<span class="arrow"></span>
					</a>					
				</div>
				<div class="l-content-bd">
					<!-- <a class="l-content" :href="telephoneNumber" v-if="userData.userDirect!==null">
						<span class="invitation-p"></span>
						<div class="title">联系推荐人{{userData.userDirect.realName}}</div>
						<span class="arrow"></span>
					</a> -->
					<a class="l-content" href="/userBundle/shareCode.mobile.html">
						<span class="invitation-p"></span>
						<div class="title">专属邀请码</div>
						<span class="arrow"></span>
					</a>
					<!-- <a class="l-content" href="/userBundle/identification.mobile.html#1">
						<span class="my-project"></span>
						<div class="title">实名认证</div>
						<span class="arrow"></span>
					</a> -->
					<a class="l-content" href="/userBundle/myAlreadyApplyProject.html">
						<span class="my-project"></span>
						<div class="title">已推项目(实名认证)</div>
						<span class="arrow"></span>
					</a>
					<a class="l-content" @click="isShowDownline=!isShowDownline">
						<span class="my-user"></span>
						<div class="title">我推广的用户</div>
						<span class="arrow" :class="{on:isShowDownline}"></span>
					</a>
					<div class="next-downline" v-if="isShowDownline">
						<div class="b-content" v-if="downLineUsers.length==0">暂无推广人</div>
						<div class="b-content" v-for="downLine in downLineUsers">
							<div class="title"><span class="user-ico"></span>下线用户：{{downLine.telephone}}<span class="gold-ico" v-if="downLine.type==1"></span></div>
							<div class="next-down">已经推广 {{downLine.downLine}} 人</div>
						</div>
					</div>
					
					<a class="l-content" href="myRequiremtnts.mobile.html">
						<span class="my-demand"></span>
						<div class="title">我发布的需求</div>
						<span class="arrow"></span>
					</a>
				</div>
				<div class="connect-us-c">
					<span style="margin-top: .3rem;">客服微信号</span>
					<span>13248643888</span>
				</div>
				<div class="wap-comfirm-button" @click="logoutAccount()">退出账号</div>

			</div>
		</div>
		<script src="../js/js/rem_fix.js"></script>
		<script src="../js/js/common.js"></script>
		<script type="text/javascript">
			var token = getCookie("userToken");
			var userId = getCookie("userId");
			console.log(token)
			console.log(userId)
			var projectId = parseInt(window.location.hash.split("#")[1]);
			var loginUrl = "../userBundle/login.mobile.html";

			var bankListApp = new Vue({
				el: '#userCenter',
				data: {
					userData: {projectIdStatus:null},
					downLineUsers: [],
					isShowDownline: true,
					isTeamLeader:false,
					accountType:null,
					refundReason:[]
				},
				computed:{
					telephoneNumber:function(){
						return 'tel:'+this.userData.userDirect.telephone;
					},
					isIng:function(){
						var isIng=false
						this.userData.projectIdStatus.forEach(function(project){
							if(project.status==1){	
								isIng=true
							}
						})
						return isIng
					}
				},
				ready: function() {
					if (!token || !userId) {
						window.location.href = loginUrl;
					} else {
						$("#userCenter").show();
						var url = "/user/getUserById";
						var data = {
							client: 1,
							token: token,
							userId: parseInt(userId)
						}
						pushData(url, data, function(res) {
							console.log(res)
							if (res.state) {
								this.userData = res.data.user;
								this.downLineUsers = res.data.downLineUsers;
								this.isTeamLeader=res.data.isTeamLeader;
								this.accountType=res.data.user.type;
								this.getGoldAccountStatus()	
								console.log(this.isIng)
							} else if (res.errorCode == 008) {
								window.location.href =loginUrl;
							} else {
								alert(res.message)
							}
						}.bind(this))
					}
				},
				filters: {
					userCategory: function(key) {
						key = parseInt(key);
						var map = {
							1: "普通用户",
							2: "vip用户",
							3: "pos联盟股东",
						};
						return map[key];
					}
				},
				methods: {
					getGoldAccountStatus:function(){			
						this.userData.projectIdStatus.forEach(function(item){
							if(item.status=='4'){
								this.refundReason.push({id:item.id,reason:item.rejectReason})
							}
						}.bind(this))
						
					},
					applyProjectItem: function() {
						if (this.isApplyProjectItem) {
							return;
						}
						if (!this.payAccount) {
							alert("支付账户必填");
							return;
						}
						if (!this.telephone) {
							alert("手机号必填");
							return;
						}
						this.isApplyProjectItem = true;
						var url = "/project/applyProjectItem";
						var data = {
							address: this.address,
							client: 1,
							doc: "",
							payAccount: this.payAccount,
							payType: this.payType,
							projectId: projectId,
							projectItemId: this.projectItems[0].id,
							telephone: this.telephone,
							token: token,
							userId: userId
						};
						pushData(url, data, function(res) {
							if (res.state) {
								alert("提交成功");
							} else if (res.errorCode == 008) {
								window.location.href = loginUrl;
							} else {
								alert(res.message);
							}
						}.bind(this));
					},
					showMessageIng:function(){
						alert("您的矿机已经在审核中，请耐心等待")
					},
					logoutAccount: function() {
						delCookie("userToken");
						delCookie("userId");
						delCookie("invitationCode");
						delCookie("accountType")
						window.location.href = loginUrl;
					},
				}
			})
		</script>

	</body>
</html>
